/**
 * @(#)ApkConfigController.java 2017年06月07日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;
import java.util.HashMap;
import java.util.Map;

import org.jsbd.boss.domian.DataIncBean;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.common.ResponseMapUtils;
import org.jsbd.boss.service.IDataIncBeanService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/dataInc")
public class DataIncController{

	private static final Logger LOGGER=LoggerFactory.getLogger(DataIncController.class);
	
	@Autowired
	private IDataIncBeanService dataIncBeanService;

	/**
	 * 后台配置页面
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "listModel")
	public String showDataIncList(Model model) throws Exception {
		return "/dataInc/dataIncList";
	}

	@RequestMapping(value = "saveDataInc")
	@ResponseBody
	public Object saveDataInc(DataIncBean dataInc){
		dataInc.setStatus(0);
		dataIncBeanService.saveDataInc(dataInc);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "updateDataInc")
	@ResponseBody
	public Object updateDataInc(DataIncBean dataIncBean){
		Map<String, String> resultMap = new HashMap<String, String>();
		if (dataIncBean.getId() == null) {
			return ResponseMapUtils.responseFail("参数非法");
		}
		DataIncBean conditon=new DataIncBean();
		conditon.setId(dataIncBean.getId());
		DataIncBean temp=dataIncBeanService.getDataIncBean(conditon);
		if(temp==null){
			return ResponseMapUtils.responseFail("记录找不到");
		}
		
		dataIncBeanService.updateDataIncBean(dataIncBean);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "getDataIncListPage")
	@ResponseBody
	public Map<String, Object> getDataIncListPage(DataGridModel page, DataIncBean dataInc) throws Exception {
		return dataIncBeanService.getDataIncListPage(page, dataInc);
	}
	
	@RequestMapping(value = "updateDataIncStatus")
	@ResponseBody
	public Map<String, Object> updateDataIncStatus(DataIncBean dataInc) throws Exception {
		dataIncBeanService.updateDataIncStatus(dataInc);
		return ResponseMapUtils.responseSuccess();
	}
	

}
